package com.seewo.dubbo.debugger.admin.query;

import com.seewo.dubbo.debugger.admin.common.validate.ValidatorUtil;
import com.seewo.dubbo.debugger.admin.common.validate.group.Query;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Pattern;

/**
 * @author chenliangliang
 * @date 2018/8/2
 */
@Data
public class ServiceQuery {

    @NotBlank(message = "协议不能为空",groups = {Query.class})
    private String protocol;
    @NotBlank(message = "链接地址不能为空",groups = {Query.class})
    @Pattern(regexp = "(\\d|[1-9]\\d|1\\d{2}|2[0-5][0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-5][0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-5][0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-5][0-5]):([0-9]|[1-9]\\d{1,3}|[1-5]\\d{4}|6[0-5]{2}[0-3][0-5])",
    message = "ip:port格式错误",groups = {Query.class})
    private String address;
    private String name;
    private String protocolFilter;


    public static void main(String[] args) {
        ServiceQuery serviceQuery = new ServiceQuery();
        serviceQuery.setProtocol("redis");
        serviceQuery.setAddress("172.18.91.166:20880");

        ValidatorUtil.validate(serviceQuery,Query.class);
    }
}
